package timeline

import (
	"gitee.com/mootok/mootok/src/models"
	"gitee.com/mootok/mootok/src/storage/database"
)

func (s *Service) GetByCategory(amount int, categoryId int, cursor int) ([]int, error) {
	var videoIds []int

	err := database.Client.Model(&models.VideoCategory{}).
		Where("category_id = ? AND id > ?", categoryId, cursor).
		Limit(amount).
		Pluck("video_id", &videoIds).
		Error
	if err != nil {
		return nil, err
	}
	return videoIds, nil
}